package org.lc.stk.model.user.permission;

import org.hibernate.annotations.Comment;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Index;
import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.Table;

/**
 * 权限基类
 * 
 * &lt;p&gt;扩展支持资源级权限控制,通过resourceId关联具体资源。
 * 权限格式: ${资源类型}:${资源ID}:${操作}&lt;/p&gt;
 */
@Entity
@Table(
    name = "permission",
    indexes = {
        @Index(name = "idx_resource_id", columnList = "resource_id")
    }
)
@Inheritance(strategy = InheritanceType.JOINED)
@Comment("权限")
public abstract class Permission {
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;

    @Column(unique = true)
    @Comment("权限代码")
    private String code;

    @Column
    @Comment("权限名称")
    private String name;

    @Column
    @Comment("权限描述")
    private String description;

    @Column
    @Comment("权限类型")
    private String type;

    @Column(name = "resource_id")
    @Comment("资源ID")
    private String resourceId;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getResourceId() {
        return resourceId;
    }

    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }
}